<template>
  <a-modal v-model="visible" :title="title" width="1500px" :footer="null">
    <a-table :columns="table.columns" :data-source="table.loadData" :pagination="table.pagination"
      @change="handleTableChange" rowKey="insureStaffId" style="margin-top: 10px;">
    </a-table>
  </a-modal>
</template>

<script>
import {
  getEnterpriseTableStaffPage
} from "@/api/human/ensureBusinessOrder"
import { mapGetters, mapActions } from 'vuex'
export default {
  name: 'AddInfo',
  data() {
    return {
      title: "",
      visible: false,
      submitLoading: false,

      table: {
        columns: [],
        loadData: [],
        pagination: {
          current: 1,
          pageSize: 10,
          total: 0,
          showSizeChanger: true,
					showQuickJumper: true,
          pageSizeOptions: ["10", "20", "50", "100"],
          showTotal: total => `共有 ${total} 条数据`,
        }
      },
      pagination: { current: 1, pageSize: 10 },

      insureNo: "",
      orderStatus: "",
    }
  },
  beforeCreate() {
    this.events_form = this.$form.createForm(this, {
      name: 'events_form'
    });
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  methods: {
    // 打开编辑弹窗 
    add(insureNo, orderStatus) {
      this.visible = true;
      this.title = '人员明细';
      this.insureNo = insureNo ? insureNo : '';
      this.orderStatus = orderStatus ? orderStatus : '';
      this.loadTable(true);
    },
    // 获取列表
    async loadTable(flag) {
      let params = {};
      this.table.columns = [
        {
          title: '姓名',
          dataIndex: 'insureName',
        },
        {
          title: '企业名称',
          dataIndex: 'enterpriseName',
        },
        {
          title: '性别',
          dataIndex: 'sex',
        },
        {
          title: '身份证',
          dataIndex: 'idCard',
        },
        {
          title: '职业',
          dataIndex: 'position',
        },
        {
          title: '职业类别',
          dataIndex: 'positionType',
        },
        {
          title: '险种',
          dataIndex: 'insureType',
        },
        {
          title: '保费',
          dataIndex: 'insureFee',
        },
        {
          title: '保险方案',
          dataIndex: 'insureCase',
        },
        {
          title: '实际工作地',
          dataIndex: 'workAddress',
        }
      ];
      if (flag) {
        this.table.pagination.current = 1;
        this.table.pagination.pageSize = 10;
      }
      params.insureNo = this.insureNo;
      params.pageNum = this.table.pagination.current;
      params.pageSize = this.table.pagination.pageSize;
      const { code, data } = await getEnterpriseTableStaffPage(params);
      if (code === '1') {
        this.table.loadData = data.content;
        this.table.pagination.total = data.total || 0;
      }
    },
    handleTableChange(pagination) {
      this.table.pagination.current = pagination.current;
      this.table.pagination.pageSize = pagination.pageSize;
      this.loadTable(false);
    }
  }
}
</script>
<style lang="less"></style>
